#include "contactus.h"
#include "ui_contactus.h"

#include <QImage>
#include <QPixmap>

contactus::contactus(int SetLangureStu, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::contactus)
{
    ui->setupUi(this);

    Gui_Init(SetLangureStu);
}

contactus::~contactus()
{
    delete ui;
}

void contactus::Gui_Init(int SetLangureStu)
{
    this->setWindowFlags(
    Qt::WindowMinimizeButtonHint\
    |Qt::WindowCloseButtonHint);

    QString ImageFile = ":/image/image_first.png";
    QImage* Image = new QImage;
    QImage* ScaledImage = new QImage;

    if(!(Image->load(ImageFile)))
    {
        delete Image;
        return;
    }
    int Owidth = Image->width();
    int Oheihgt = Image->height();
    int Fwidth,Fheight;
    int lbl_width = 130;
    int lbl_height= 130;
    ui->lbl_image_first->setGeometry(0,0,lbl_width,lbl_height);
    int Mul;
    if(Owidth/lbl_width > Oheihgt/lbl_height)
        Mul = Owidth/lbl_width;
    else
        Mul = Oheihgt/lbl_height;
    Fwidth = Owidth/Mul;
    Fheight = Oheihgt/Mul;
    *ScaledImage = Image->scaled(Fwidth,Fheight,Qt::KeepAspectRatio);

    ui->lbl_image_first->setPixmap(QPixmap::fromImage(*ScaledImage));
    if(SetLangureStu == 1)
    {
        setWindowTitle("Contact Us");
        ui->lbl_name_first->setText("Customer service");
    }
    else
    {
        setWindowTitle("联系我们");
        ui->lbl_name_first->setText("智能客服");
    }
}

